<?php 

$this->headScript()
		->appendFile($this->baseUrl()."/js/jquery/development-bundle/ui/jquery.ui.core.js")
		->appendFile($this->baseUrl()."/js/jquery/development-bundle/ui/jquery.ui.widget.js")
		->appendFile($this->baseUrl()."/js/jquery/development-bundle/ui/jquery.ui.button.js");
$this->headLink()->appendStylesheet($this->baseUrl(). '/js/jquery/development-bundle/themes/ui-lightness/jquery.ui.all.css');
$this->headTitle('Productos destacados');
?>
<div class="section table_section">
<div class="section_inner">
	<div class="title_wrapper">
		<h2 id="title-section">Productos Destacados</h2>
	</div>
	<div class="section_content">
	<p class="errorText">&nbsp;<?php echo $this->messageError; ?></p>
	<div  id="product_list">
	<!--[if !IE]>start table_wrapper<![endif]-->
	<div class="table_wrapper">
		<div class="table_wrapper_inner">
		
                <table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tbody>
                	<tr>
		              	<th width="20" align="right">ID</td>
		                <th class="photo"><span>Imagen</span></th>		              	
		                <th>Producto</td>
		                <th align="left">Fecha de Inicio</td>
		                <th align="left">Fecha Final</td>
		                <th align="right">Precio</td>
		                <th align="right">Cantidad&nbsp;&nbsp;&nbsp;</td>
		                <th width="50" align="center">Estado</td>
		                <th align="right">Acción&nbsp;</td>
              		</tr>
              
		<?php 
		
		foreach ($this->Products AS $dat){
			$addproduct=true;
			$newprice=0;
			$image_url=$this->baseUrl()."/images/noimage-product_Mini_Thumb.jpg";
			if(is_array($dat['AllImagesByProduct'])){
				$totimg=count($dat['AllImagesByProduct']);
				$image_url=$this->baseUrl()."/images/files/product/Mini_Thumb/".$dat['AllImagesByProduct'][rand(0, ($totimg-1))]['MiniThumb'];
			}
		
			$newprice=$dat['Price'];
		
			if(!empty($dat['TaxPercent']) && $dat['TaxPercent'] > 0){
				$newprice = $dat['Price'] * (($dat['TaxPercent'] / 100) + 1);
			}
			
			?>
				
		              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='<?php echo $this->baseUrl(); ?>/admin/products/addfeatured/Id/<?php echo $dat['Id'];?>/'">
		                <td width="20" align="right"><?php echo $dat['Id'];?></td>
		                <td class="photo">
							<a href="#" class="product_thumb">
								<img src="<?php echo $image_url; ?>" alt="" width="44" height="31" />
							</a>
						</td>
		                <td valign="middle">
		                	<a class="product_name" href="<?php echo $this->baseUrl(); ?>/admin/products/addfeatured/?Id=<?php echo $dat['Id'];?>">
		                		<?php echo (isset($dat['Name'])) ? $dat['Name'] : '&nbsp;&nbsp;'; ?>
							</a>
		                </td>
		                <td align="center" valign="middle"><?php echo (isset($dat['StartDate'])) ? $dat['StartDate'] : '&nbsp;&nbsp;'; ?></td>
		                <td align="center" valign="middle"><?php echo (isset($dat['EndDate'])) ? $dat['EndDate'] : '&nbsp;&nbsp;'; ?></td>
		                <td align="right" valign="middle"><?php echo (isset($newprice)) ? (sprintf("%01.2f", $newprice)) : '&nbsp;&nbsp;'; ?></td>
		                <td align="right" valign="middle"><?php echo (isset($dat['Cantidad'])) ? $dat['Cantidad'] : '&nbsp;&nbsp;'; ?></td>
		                <td width="50" align="center">
		                	<?php echo ($dat['Status']=="1")? '<span class="approved">Activo</span>' : '<span class="pending">Inactivo</span>'; ?>                	
						</td>
		                <td align="right">
		                <div class="actions_menu">
							<ul>
								<li><a class="delete delete-alert" href="<?php echo $this->baseUrl(); ?>/admin/products/deletefeatured/Id/<?php echo $dat['Id'];?>/">
									<input type="hidden" name="catprod" id="catprod" value="producto" />Eliminar</a>
								</li>
							</ul>
						</div>
							
		               </td>
		              </tr>
		              
		<?php 		}
				
		?>              
		        </table>
		        </div>
        
</div>
	<!--[if !IE]>end table_wrapper<![endif]-->
	</div>
<?php echo $this->paginationControl($this->Products, 'Sliding', 'pagination.phtml'); ?>
		</div>
	</div>        

<script type="text/javascript">
$(document).ready(function(){
	$( "#addproduct" ).button();
	$("a.delete-alert").click(function(){
		
		if(confirm("Realmente desea eliminar este producto?, tenga encuenta que este proceso será irreversible")){
			return true;
		}
		return false;
	});
	
});
</script>
<div style="width:100%; text-align: right;">
<p>
	<a href="<?php echo $this->baseUrl(); ?>/admin/products/addfeatured/" id="addproduct">Nuevo producto</a>
</p>
</div>

</div>

